/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hhf.worldzones.services.locationServices.cityServices;

import hhf.flex.annotations.services.CacheServiceId;
import hhf.worldzones.daos.CityDAO;
import hhf.worldzones.entities.City;
import hhf.worldzones.exceptions.CityUnknownException;
import hhf.worldzones.exceptions.EntityUnknownException;
import java.util.List;
import org.slf4j.Logger;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.inject.Inject;

/**
 *
 * @author HHFrancois
 */
@Stateless
public class CityFacade implements CityFacadeLocal {

    @EJB
    CityDAO cityDAO;
    @Inject
    Logger logger;

    @Override
    public void remove(City entity) {
        logger.debug("remove City : " + entity.getLabel());
        //cityDAO.remove(entity);
    }

    @Override
    public void persist(City entity) {
        logger.info("persist City :" + entity.getLabel());
        //cityDAO.persist(entity);
    }

    @Override
    public City merge(City entity) {
        return cityDAO.merge(entity);
    }

    @Override
    public List<City> findRange(int[] range) {
        return cityDAO.findRange(range);
    }

    @Override
    public List<City> findAll() {
        return cityDAO.findAll();
    }

    @Override
    public int count() {
        return 111;
        //return cityDAO.count();
    }

    @Override
    public City find(@CacheServiceId String id) throws CityUnknownException {
        City c;
        try {
            c = cityDAO.find(id);
        } catch (EntityUnknownException ex) {
            throw new CityUnknownException(ex);
        }
        return c;
    }
}
